import React, {Component} from 'react';
import {HashRouter as Router, Route, Switch, Redirect} from 'react-router-dom';
import App from './App';
import Admin from './admin';
import Login from './pages/login';
import NoMatch from './pages/nomatch';
import Home from './pages/home';
import Buttons from './pages/ui/buttons';
import Modals from './pages/ui/modals';
import Spins from "./pages/ui/spins";
import Drags from "./pages/ui/drags/index";
import Notifications from "./pages/ui/notifications";
import Messages from "./pages/ui/messages";
import Progresses from "./pages/ui/progresses";
import Carousels from "./pages/ui/carousels";
import FormLogin from "./pages/form/login";
import FormRegister from "./pages/form/register";
import TableBasic from "./pages/table/basic";
import TableAdvanced from "./pages/table/advanced";
import User from './pages/system/user';
import Role from './pages/system/role';
import Resource from './pages/system/resource';

class AdminRouter extends Component {
    render() {
        return (
            <Router>
                <App>
                    <Switch>
                        <Redirect exact from={'/'} to={'/login'}/>
                        <Route path={'/login'} component={Login}/>
                        <Route path={'/admin'} render={() =>
                            <Admin>
                                <Switch>
                                    <Redirect exact from={'/admin'} to={'/admin/home'}/>
                                    <Route path={'/admin/home'} component={Home}/>
                                    <Route path={'/admin/ui/buttons'} component={Buttons}/>
                                    <Route path={'/admin/ui/modals'} component={Modals}/>
                                    <Route path={'/admin/ui/spins'} component={Spins}/>
                                    <Route path={'/admin/ui/drags'} component={Drags}/>
                                    <Route path={'/admin/ui/notifications'} component={Notifications}/>
                                    <Route path={'/admin/ui/messages'} component={Messages}/>
                                    <Route path={'/admin/ui/progresses'} component={Progresses}/>
                                    <Route path={'/admin/ui/carousels'} component={Carousels}/>
                                    <Route path={'/admin/form/form-login'} component={FormLogin}/>
                                    <Route path={'/admin/form/form-register'} component={FormRegister}/>
                                    <Route path={'/admin/table/basic'} component={TableBasic}/>
                                    <Route path={'/admin/table/advanced'} component={TableAdvanced}/>
                                    <Route path={'/admin/system/users'} component={User}/>
                                    <Route path={'/admin/system/roles'} component={Role}/>
                                    <Route path={'/admin/system/resources'} component={Resource}/>
                                    <Route component={NoMatch}/>
                                </Switch>
                            </Admin>
                        }/>
                        <Route component={NoMatch}/>
                    </Switch>
                </App>
            </Router>
        );
    }
}

export default AdminRouter;